﻿namespace Innovative.ProXr
{
	/// <summary>
	/// Provides a full set of static methods to communicate with the relay controller
	/// supporting all documented commands.
	/// </summary>
	public static partial class DirectApi
	{
		/// <summary>
		/// These commands will retrieve or change the configuration of the relay controller.
		/// </summary>
		public static class Configuration
		{
			/// <summary>
			/// Test 2-Way Communications is used to verify the controller is properly communicating. This command will respond with one of the following 
			/// responses based on the current mode of the device:
			/// 85 is returned if the controller is in run mode
			/// 86 is returned if the controller is in configuration mode
			/// 87 is returned if the controller is in security lockdown mode
			/// </summary>
			public static RelayCommandSet<ConfigurationMode> GetMode = new RelayCommandSet<ConfigurationMode>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 33)
				},
				ExpectedResults = new RelayByte[] { 85, 86, 87 },
				ResponseConverter = new ConfigurationModeResponseConverter()
			};

			/// <summary>
			/// The ProXR Series Controllers can be connected to a
			/// computer or microcontroller using as little as two wires.
			/// When used in 1-way mode, reporting should be turned off
			/// for highest communication speed. Turning off reporting
			/// will allow you to send commands to the ProXR Series
			/// Controllers much faster, but it is impossible to ask the
			/// controller for the status of relays when wired as shown
			/// below.
			/// </summary>
			public static RelayCommandSet<bool> ActivateReportingMode = new RelayCommandSet<bool>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 27)
				},
				ExpectedResults = new RelayByte[] { 85 },
				ResponseConverter = new Boolean85ResponseConverter()
			};

			/// <summary>
			/// The ProXR Series Controllers can be connected to a
			/// computer or microcontroller using as little as two wires.
			/// When used in 1-way mode, reporting should be turned off
			/// for highest communication speed. Turning off reporting
			/// will allow you to send commands to the ProXR Series
			/// Controllers much faster, but it is impossible to ask the
			/// controller for the status of relays when wired as shown
			/// below.
			/// </summary>
			public static RelayCommandSet<bool> DeactivateReportingMode = new RelayCommandSet<bool>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 28)
				},
				ExpectedResults = new RelayByte[] { 85 },
				ResponseConverter = new Boolean85ResponseConverter()
			};
		}
	}
}
